#include <iostream>

using namespace std;

const int N = 1010;
int b[N][N], a[N];
int n;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			cin >> b[i][j];
		}
	}
	a[1] = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(i == j) continue;
			a[i] |= b[i][j] ;
		}
	}

	for(int i = 1; i <= n; i++)
	cout << a[i] << " ";
}
